<?php
/**
 * Yotaku
 * Copyright (c) 2016 http://www.yotaku.net All rights reserved.
 * Author: Creatint <creatint@163.com> <http://creatint.net>
 */
include_once 'lib/BmobObject.class.php';
include_once 'lib/BmobUser.class.php';
include_once 'lib/BmobBatch.class.php';
include_once 'lib/BmobFile.class.php';
include_once 'lib/BmobImage.class.php';
include_once 'lib/BmobRole.class.php';
include_once 'lib/BmobPush.class.php';
include_once 'lib/BmobPay.class.php';
include_once 'lib/BmobSms.class.php';
include_once 'lib/BmobApp.class.php';
include_once 'lib/BmobSchemas.class.php';
include_once 'lib/BmobTimestamp.class.php';
include_once 'lib/BmobCloudCode.class.php';
include_once 'lib/BmobBql.class.php';

class Api {


    public function send($mobile, $mobile_code){
//        var_dump(C());

        ////短信相关
        $bmobSms = new \BmobSms();
        $res = $bmobSms->sendSmsVerifyCode($mobile, "Yotaku验证");  //发送短信验证码
//         $res = $bmobSms->sendSms($mobile, "您的验证码是：222222, 有效期是10分钟。"); //发送短信
//         $res = $bmobSms->verifySmsCode($mobile,$mobile_code);  //发送短信验证码
//         $res = $bmobSms->querySms("6466181");  //查询短信状态

        return $res;
    }

    public function check($mobile, $mobile_code){
        ////短信相关
        $bmobSms = new \BmobSms();
//        $res = $bmobSms->sendSmsVerifyCode($mobile, "Yotaku验证");  //发送短信验证码
//         $res = $bmobSms->sendSms($mobile, "您的验证码是：222222, 有效期是10分钟。"); //发送短信
         $res = $bmobSms->verifySmsCode($mobile,$mobile_code);  //发送短信验证码
        
        if($res->msg == 'ok'){
            // code is right, set session

            session('verification_code',$mobile_code);
        }else{
            // code is false
            return false;
        }
//         $res = $bmobSms->querySms("6466181");  //查询短信状态

        return $res;
    }

}